﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business;
using Database;

namespace DT5_Anh09110006_Hung09110044_Vu09110157
{
    public partial class TaiLieuHocTap : System.Web.UI.Page
    {
        QuanLyTaiLieu qlTaiLieu = new QuanLyTaiLieu();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack){
                LoadDuLieu();
            }
        }

        private void LoadDuLieu(){
            try
            {
                grvTaiLieu.DataSource = qlTaiLieu.LayDanhSachTaiLieu();
                grvTaiLieu.DataBind();
            }
            catch(Exception ex){
                Response.Redirect("~/ErrorPage.aspx");
            }
        }
        protected void grvTaiLieu_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            grvTaiLieu.PageIndex = e.NewPageIndex;
            LoadDuLieu();
        }

        protected void grvTaiLieu_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if(e.CommandName.Equals("TaiFile")){
                Response.Redirect("~/Upload/" + e.CommandArgument);
            }
        }
    }
}